package com.test.damn.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.context.RequestContext;
import com.netflix.zuul.exception.ZuulException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * 拦截器
 *
 * @author hedongzhou
 * @since 2020/03/05
 */
@Component
@Slf4j
public class ApiFilter extends ZuulFilter {

    @Override
    public String filterType() {
        return "pre";
    }

    @Override
    public int filterOrder() {
        return 0;
    }

    @Override
    public boolean shouldFilter() {
        return true;
    }

    @Override
    public Object run() throws ZuulException {
        RequestContext curContext = RequestContext.getCurrentContext();
        HttpServletRequest request = curContext.getRequest();
        log.info("uri={}", request.getRequestURI());
        return null;
    }

}
